<template>
	<view class="page">
		<view class="page-wrap">
			<view class="page-top">
				<view class="logo-box">
					<image :src="getAssets(`@/static/static-online/fans/invite-title.png`)" mode=""></image>
				</view>
			</view>


			<view class="page-ctx">
				<view class="share-wrap">
					<!-- 分享海报 -->
					<l-painter css="width: 686rpx;padding: 48rpx; margin: 0 auto; background: #FFFFFF;box-sizing: border-box; "
						@fail="fail" pathType="url" ref="share_poster">
						<l-painter-view css="background:#FFFFFF;">

							<!-- <l-painter-view css="background:#F5F7F9;margin-top:70rpx;text-align:center;">
								<l-painter-text text="邀请好友加入 NUOCHE"
									css="text-align:center;font-size: 48rpx;font-weight: bold;color: #333333;">
								</l-painter-text>
								<l-painter-text text="邀请好友购买商品，赚取相应佣金"
									css="margin-top: 16rpx;text-align:center;font-size: 24rpx;color: #999999;">
								</l-painter-text>
							</l-painter-view> -->


							<!--  -->
							<!-- 中间logo 二维码 -->
							<l-painter-view
								css="background:#FFFFFF;margin-top:0rpx;padding-top: 0rpx;padding-bottom: 70rpx;text-align:center;">
								<l-painter-image :src="image_logo" css="width:202rpx;height:188rpx;display:block;margin:0 auto;" />

								<l-painter-text text="分享链接   扫码购票"
									css="margin-top: 26rpx;text-align:center;font-size: 24rpx;color: #A8ADB7;font-weight: 400;">
								</l-painter-text>


								<l-painter-view
									css="position:relative;width:296rpx;height:264rpx;margin:0 auto;margin-top:76rpx;dispaly:flex; justify-content: center; align-items: center;">
									<l-painter-image :src="image_code_wrap"
										css="display:block;width:296rpx;height:264rpx;margin:0 auto;" />

									<l-painter-view
										css="position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:192rpx;height:192rpx">
										<l-painter-image :src="image_code"
											css="display:block;width:192rpx;height:192rpx;margin:0 auto;" />

									</l-painter-view>

								</l-painter-view>


							</l-painter-view>
							<!--  -->
						</l-painter-view>
					</l-painter>
					<!-- 分享海报 -->
				</view>

				<view class="foot-btns">
					<!-- 	<view class="btn flex-center" @click="share_poster_save()">
						保存
					</view> -->
					<button open-type="share" class="btn flex-center">
						分享链接
					</button>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// image_logo: require('@/static/fans/invite-logo.png'),
				image_logo: '',
				image_code_wrap: require('@/static/fans/invite-code-wrap.png'),
				image_code: '',
				// image_code_demo: require('@/static/fans/code-demo.png'),
			}
		},
		computed: {

		},
		onLoad(options) {
			this.image_code = this.getAssets(`@/static/static-online/fans/invite-logo.png`);
			this.queryUserPoster();
		},

		onShow() {
			this.$log('配置', {
				...this.vuex_config
			})
		},
		methods: {
			queryUserPoster() {
				this.$api({
					url: '/service.php',
					method: 'get',
					data: {
						action: 'users_shareInfo',
					},
				}).then(res => {
					if (res.code == 200) {
						this.image_code = res.data.code
					}
				})
			},
			
			share_poster_save() {
				this.$refs.share_poster.canvasToTempFilePathSync({
					fileType: 'jpg',
					quality: 1,
					success: (res) => {
						console.log(res.tempFilePath)
						this.picture2 = res.tempFilePath

						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success: function() {
								uni.showToast({
									title: '保存成功',
									duration: 4000
								})
							},
							fail() {
								// uni.hideLoading()
							}
						});
					}
				})
			},
		}
	}
</script>


<style lang="less" scoped>
	.page {
		.page-wrap {
			padding: 0;
			height: 100%;
			box-sizing: border-box;
			background: #FFFFFF;
		}



		.page-top {
			padding: 80rpx 0;

			.logo-box {
				width: 448rpx;
				height: 72rpx;
				margin: 0 auto;

				image {
					width: 448rpx;
					height: 72rpx;
				}
			}
		}

		.page-ctx {
			padding: 0 32rpx;
		}

		.share-wrap {
			box-shadow: 0rpx 0rpx 16rpx 2rpx rgba(0, 0, 0, 0.08);
			border-radius: 16rpx 16rpx 16rpx 16rpx;

			margin-bottom: 88rpx;
		}
	}



	.foot-btns {
		margin-top: 88rpx;

		.btn {
			height: 88rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 0rpx 16rpx 2rpx rgba(0, 0, 0, 0.08);
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 32rpx;
			color: #333333;
		}
	}
</style>